package com.zackratos.component2

import java.lang.ref.WeakReference

/**
 * @Author   : zhangwenchao
 * @Date     : 2020/12/29  9:55 PM
 * @Describe :
 */
class Component2Operator private constructor() {

    companion object {
        fun getInstance() = Holder.INSTANCE
    }

    private object Holder {
        val INSTANCE = Component2Operator()
    }

    var fragment: WeakReference<Component2Fragment>? = null

    fun registerFragment(fragment2: Component2Fragment) {
        fragment = WeakReference(fragment2)
    }

    fun unRegisterFragment() {
        fragment = null
    }

    fun updateBottomText(content: String?) {
        fragment?.get()?.updateBottomText(content)
    }

    fun updateTopText(content: String?) {
        fragment?.get()?.updateTopText(content)
    }

}